home *** CD-ROM | disk | FTP | other *** search
- Geoff Arnold @ Sun BOS - R.H. coast near the top writes:
- >
- >I believe that there was unanimity during the design meetings that a
- >successful call would _not_ modify the internal error variable accessed
- >via WSAGetLastError(). The intention was to mirror the semantics of the
- >Unix "errno" variable - indeed it is possible to #define errno as a
- >...
- >
- > descriptions specify the details. An error number is also
- > made available in the external variable errno. errno is not
- > cleared on successful calls, so it should be tested only
- > after an error has been indicated.
-
- Picking a nit, but I think an important one. The above says "...is not
- CLEARED...". It does NOT say "...is not MODIFIED..."! Maybe this isn't
- a problem with very-latest-wonder-Unices, but I've found to my great
- chagrin that one CANNOT rely on errno having ANY particular value after
- any successful library calls - and that includes value-as-of-last-error.
-
- In other words, you not only can't rely on errno being cleared by
- successful calls, you also can't rely on it containing the last error
- which occurred, unless you test it IMMEDIATELY after the error occurred.
-
- Fundamental defensive programming, really - if you need to look at the
- value of some external object over which you have no control, you'd
- better save your own copy as-of the snapshot of time for which you're
- interested in the value - don't assume it didn't change while you weren't
- looking. Treat "extern" as "volatile".
-
- --
- Carl Paukstis, RRR&RSG Spokane, Washington, USA carlp@mail.spk.olivetti.com
- 1KQSPI: 8.80 DoD#0432 Oli North: not responsible. carlp@frigg.isc-br.com
- From rcq@ftp.com Sat Oct 16 12:40:10 1993
- Received: from ftp.com by SunSITE.unc.edu (SMI4.1/FvK 1.02)
- id AA04295; Sat, 16 Oct 93 12:40:10 EDT
- Received: from rcq.oysters.ftp.com by ftp.com via PCMAIL with DMSP
- id AA29018; Sat, 16 Oct 93 12:40:21 -0400
- Date: Sat, 16 Oct 93 12:40:21 -0400
- Message-Id: <9310161640.AA29018@ftp.com>
- To: Geoff.Arnold@east.sun.com
- Subject: Re: WSAGetLastError() on success
- From: rcq@ftp.com (Bob Quinn)
- Reply-To: rcq@ftp.com
- Cc: Multiple recipients of list <winsock@sunsite.unc.edu>
- Sender: rcq@ftp.com
- Repository: babyoil.ftp.com
- Originating-Client: oysters.ftp.com
-
- > >> the v1.1 specification does not explicitly say WSAGetLastError()
- > >> can be used to indicate the success of the previous function.
- ...
- > In other words, the successful
- > function call would appear to have failed!
-
- This was exactly the case that started this thread. WSAGetLastError()
- returned an error after a successful call to accept(). The programmer
- thought our DLL was returning a bogus error. Actually, we were returning
- a valid error from a previously failed WinSock function call.
-
- --
- Bob Quinn rcq@ftp.com
- FTP Software, Inc. No. Andover, MA
-
-